home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-07-14 | 2.4 KB | 108 lines | [TEXT/CWIE] |
- /*************************************************************************************
-
- File: ISpSampleUSBMain.cp
-
- Copyright © 1996, 1997, 1998 Apple Computer, Inc., All Rights Reserved
-
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- *************************************************************************************/
-
-
- #ifndef __FOLDERS__
- #include <Folders.h>
- #endif
-
- #ifndef __FILES__
- #include <Files.h>
- #endif
-
- #ifndef __CODEFRAGMENTS__
- #include <CodeFragments.h>
- #endif
-
- #ifndef __USB__
- #include <USB.h>
- #endif
-
- #include "ISpSampleUSB.h"
- #include "ISpSampleUSBRes.h"
-
- #include "dprintf.h"
-
-
-
- // type = shlb
- // creator = insp
-
- #if __MWERKS__
- extern "C" __initialize(CFragInitBlockPtr ibp);
- extern "C" __terminate(void);
- #endif
- extern "C" OSErr __myinitialize(CFragInitBlockPtr ibp);
- extern "C" void __myterminate(CFragInitBlockPtr ibp);
-
- // Initialization routine for when the library is "opened" by an app
- OSErr __myinitialize(CFragInitBlockPtr ibp)
- {
- #if __MWERKS__
- OSErr err = noErr;
- err = __initialize(ibp);
-
- if (err != noErr)
- return err;
- #endif
-
- UInt32 inputSprocketVersion = * (UInt32 *) &(ISpGetVersion());
-
- // require InputSprocket 1.1.0
- if (inputSprocketVersion < 0x01100000)
- return noErr;
-
- // if we can't find USBManager, exit gracefully
- if ((Ptr) USBGetNextDeviceByClass == (Ptr) kUnresolvedCFragSymbolAddress)
- return noErr;
-
- // Grab the file spec
- FSSpec fileSpec = {0,0,0};
- if (ibp->fragLocator.where == kDataForkCFragLocator)
- {
- // The shared library should always be located in the data fork
- fileSpec = *ibp->fragLocator.u.onDisk.fileSpec;
- }
-
- ISpUSBDevice::Initialize(fileSpec);
-
- return noErr; // we don't create an IS device, so IS will unload us
- }
-
- // Termination routine. • More TBD here.
- void __myterminate(CFragInitBlockPtr ibp)
- {
- #pragma unused(ibp)
-
- ISpUSBDevice::Terminate();
-
- #if __MWERKS__
- __terminate();
- #endif
- }
-
- void *operator new(size_t size)
- {
- return NewPtrSys(size);
- }
-
- void operator delete(void *ptr)
- {
- DisposePtr((Ptr) ptr);
- }
-
-